// 轮播图
let mySwiper=new Swiper('.swiper-container',{
    width:610,
    height:380,
    loop:true,
    initialSlide:2,
    speed:300,
    grabCursor:true,
    autoplay:{
        delay:2000,
    },
    effect:'slide',
    pagination:{
        el:'.swiper-pagination',
    },
    navigation:{
        nextEl:'.swiper-button-next',
        prevEl:'.swiper-button-prev',
        hideOnClick: true,
    }
})
// 吸顶
window.addEventListener("scroll",()=>{
    let scrollTop = document.documentElement.scrollTop || document.body.scrollTop; 
    let offsetTop = document.querySelector('.xiDing').offsetTop;
    if (scrollTop > offsetTop) {
        document.querySelector('.xiDing').style.display="block";
         document.querySelector('.xiDing').style.position="fixed";
         document.querySelector('.xiDing').style.top="0px";
         document.querySelector('.xiDing').style.left="160px";
         document.querySelector('.xiDing').style.zIndex="999";
       
    } else {
         document.querySelector('.xiDing').style.position="";
         document.querySelector('.xiDing').style.top="";
        document.querySelector('.xiDing').style.display="none";
         
    }})
//楼层导航
$('.bodUl>li:last()').click(()=>{
    $('html').animate({
        scrollTop:0
    },800)
})
$('.bodUl>li:first()').click(function(){
    window.scrollTo({
        top:$('.secTop').offset().top-250,
        behavior:'smooth',
    })

})
$('.bodUl>li').eq(1).click(function(){
    window.scrollTo({
        top:$('.mainTop').offset().top-220,
        behavior:'smooth',
    })

})
// 搜索
const search=document.querySelector('.input0')
const searchUl=document.querySelector('.searchUl')
// const xiDing2=document.querySelector('.xiDing2')

search.oninput=function(){
    const text=this.value
    const script=document.createElement('script')
    script.src = 'https://www.baidu.com/sugrec?pre=1&p=3&ie=utf-8&json=1&prod=pc&from=pc_web&sugsid=34099,33970,34004,33855,33607,26350,22159&wd=' + text + '&req=2&csor=5&pwd=aiqiyi&cb=fn&_=1623047595324'
    document.body.appendChild(script)
    script.remove()
}
function fn(res){
    if(!res.g){
        searchUl.style.display='none'
        return
    }
    let str=''
    res.g.forEach(item=>{
        str+=`<li>${item.q}</li>`

    })
    searchUl.innerHTML=str
    searchUl.style.display='block'
    // xiDing2.innerHTML=str
    // xiDing2.style.display='block'
}


